﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScheduleMaker.DB.Domain;
using NHibernate.Criterion;
using NHibernate;
using ScheduleMaker.DB.Domain.Core;

namespace ScheduleMaker.DB
{
    //TODO: po czym chcemy szukac?
    public class ClassroomDAOUniversity : AbstractDAO<ClassroomUniversity>
    {

        public IList<ClassroomUniversity> getClassroomsBySubject(Subject subject)
        {
            IList<ClassroomUniversity> classrooms = getAll();
            IList<ClassroomUniversity> returned = new List<ClassroomUniversity>();
            foreach(var classroom in classrooms) {
                bool member = true;
                foreach (var eq in subject.Equipments)
                {
                    if (!classroom.Equipments.Contains(eq))
                    {
                        member = false;
                        break;
                    }
                }
                if (member)
                    returned.Add(classroom);
            }

            return returned;
        }

    }
}
